package com.guoxue.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.guoxue.dao.IGoodBookRecordDao;
import com.guoxue.domain.GoodBookRecordVo;

@Repository
public class GoodBookRecordDaoImpl extends BaseDaoImpl<GoodBookRecordVo> implements IGoodBookRecordDao{

	@Override
	public GoodBookRecordVo getGoodBookRecord(int workId) {
		return get("FROM GoodBookRecordVo g WHERE g.workId = ?", new Object[]{String.valueOf(workId)});
	}

	@Override
	public void saveGoodBookRecord(GoodBookRecordVo goodBookRecord) {
		saveOrUpdate(goodBookRecord);
	}

	@Override
	public GoodBookRecordVo getGoodBookRecord(Integer uid, String workId) {
		return get("FROM GoodBookRecordVo g WHERE g.uid = ? AND g.workId = ?", new Object[]{uid,String.valueOf(workId)});
	}

	@Override
	public List<GoodBookRecordVo> getGoodBookRecordList(Integer uid) {
		return find("FROM GoodBookRecordVo g WHERE g.uid = ? ORDER BY g.createTime DESC",new Object[]{uid});
	}

	@Override
	public GoodBookRecordVo getGoodBookRecord(Integer uid, String workId, Integer type) {
		return get("FROM GoodBookRecordVo g WHERE g.uid = ? AND g.workId = ? AND g.type = ?", new Object[]{uid,String.valueOf(workId),type});
	}

	@Override
	public List<GoodBookRecordVo> getGoodBookRecordList(Integer uid, int i) {
		return find("FROM GoodBookRecordVo g WHERE g.uid = ? AND g.type = ? ORDER BY g.createTime DESC",new Object[]{uid,i});
	}

}
